home *** CD-ROM | disk | FTP | other *** search
- property pMySpriteNum, pState, pLocation, pVelocity, pCurrAnim, pAnimations, pCurrFrame, pLastAnimationUpdate, pInvincibleTimer, pbInvincible, MAX_SPEED, INVINCIBLE_TIME, pLast
- global gLives, gBallDead, gEnemyCount2, gLevel, gWon, gScore, gBallSpriteNum
-
- on new me, mySpriteNum, myLocation
- pLast = 0
- pMySpriteNum = mySpriteNum
- gBallSpriteNum = pMySpriteNum
- pState = #flying
- pLocation = myLocation
- pVelocity = [0.0, 0.0, 0.0]
- sprite(pMySpriteNum).puppet = 1
- sprite(pMySpriteNum).member = member(46)
- sprite(pMySpriteNum).ink = 8
- sprite(pMySpriteNum).loc = point(pLocation[1], pLocation[2])
- pCurrAnim = #flying
- pAnimations = [#Run: [46, 47, 48, 49, 50, 51, 52, 53, 54, 55], #takeOff: [46, 47, 48, 49, 50, 51, 52, 53, 54, 55], #flying: [46, 47, 48, 49, 50, 51, 52, 53, 54, 55], #dead: [46, 47, 48, 49, 50, 51, 52, 53, 54, 55]]
- pCurrFrame = 1
- pLastAnimationUpdate = the ticks
- MAX_SPEED = 4.0
- INVINCIBLE_TIME = 120
- pInvincibleTimer = the ticks + 120
- pbInvincible = 1
- return me
- end
-
- on update me
- if gBallDead = 1 then
- sprite(10).blend = sprite(10).blend - 10
- if sprite(10).blend < 20 then
- sprite(10).blend = 0
- sprite(10).visible = 0
- end if
- end if
- if gBallDead = 1 then
- if (gLevel = 1) or (gLevel = 2) then
- if sprite(10).locV > 360 then
- setState(#dead)
- end if
- end if
- if (gLevel = 3) or (gLevel = 4) or (gLevel = 5) then
- if sprite(10).locV > 380 then
- setState(#dead)
- end if
- end if
- end if
- if pState <> #dead then
- if pState <> #takeOff then
- collisionCheck()
- end if
- enemyCollisionCheck()
- handleInput()
- theAngle = getAngle(pLocation, the mouseLoc)
- if the stillDown and (gBallDead = 0) then
- if pState = #onGround then
- pVelocity[2] = -2.0
- setState(#flying)
- else
- if pState = #flying then
- radAngle = theAngle * PI / 180
- oX = cos(radAngle) * 1.0
- oY = -sin(radAngle) * 1.0
- pVelocity = pVelocity + [oX, oY]
- end if
- end if
- else
- if pState = #flying then
- end if
- end if
- end if
- case pState of
- #onGround:
- if (pVelocity[1] > -1.0) and (pVelocity[1] < 1.0) then
- pVelocity[1] = 0.0
- end if
- if pVelocity[1] <> 0.0 then
- else
- sprite(pMySpriteNum).member = member(46)
- end if
- if pVelocity[2] > 0.0 then
- pVelocity[2] = 0.0
- end if
- pLocation = pLocation + pVelocity
- #flying:
- pVelocity[2] = pVelocity[2] + 0.20000000000000001
- pLocation = pLocation + pVelocity
- #dead:
- if pCurrAnim <> #dead then
- else
- if keyPressed(SPACE) then
- respawn()
- end if
- if pLocation[2] < 400 then
- pVelocity[1] = pVelocity[1] * 0.90000000000000002
- pVelocity[2] = pVelocity[2] + 0.20000000000000001
- pLocation = pLocation + pVelocity
- else
- if pCurrAnim <> #dead then
- puppetSound(4, "cricketguyfall")
- pCurrAnim = #dead
- pCurrFrame = 1
- pLocation[2] = 400
- end if
- end if
- end if
- end case
- if pLocation[1] < -5.0 then
- pLocation[1] = 580.0
- end if
- if pLocation[1] > 585.0 then
- pLocation[1] = 0.0
- end if
- if pLocation[2] < 12.0 then
- pLocation[2] = 12.0
- pVelocity[2] = 0.0
- end if
- sprite(pMySpriteNum).loc = point(pLocation[1], pLocation[2])
- if pVelocity[1] > MAX_SPEED then
- pVelocity[1] = MAX_SPEED
- end if
- if pVelocity[2] > MAX_SPEED then
- pVelocity[2] = MAX_SPEED
- end if
- if pVelocity[1] < -MAX_SPEED then
- pVelocity[1] = -MAX_SPEED
- end if
- if pVelocity[2] < -MAX_SPEED then
- pVelocity[2] = -MAX_SPEED
- end if
- end
-
- on handleInput
- if pLocation[1] < (the mouseLoc)[1] then
- if pVelocity[1] < MAX_SPEED then
- pVelocity[1] = pVelocity[1] + 0.5
- end if
- else
- if pLocation[1] > (the mouseLoc)[1] then
- if pVelocity[1] > -MAX_SPEED then
- pVelocity[1] = pVelocity[1] - 0.5
- end if
- end if
- end if
- if gBallDead = 1 then
- sprite(150).visible = 1
- sprite(pMySpriteNum).member = "ballDead"
- end if
- end
-
- on setState theState
- case theState of
- #onGround:
- pState = #onGround
- pCurrAnim = #Run
- pCurrFrame = 1
- #takeOff:
- pState = #takeOff
- pCurrAnim = #takeOff
- pCurrFrame = 1
- #flying:
- pState = #flying
- pCurrAnim = #flying
- pCurrFrame = 1
- #dead:
- pState = #dead
- pCurrAnim = #flying
- pCurrFrame = 1
- end case
- end
-
- on collisionCheck
- c = sendSprite(0, #levelCollisionCheck, pMySpriteNum)
- if gBallDead = 1 then
- case gLevel of
- 1:
- if c <> 6 then
- exit
- end if
- 2:
- if c <> 2 then
- exit
- end if
- 3:
- if c <> 7 then
- exit
- end if
- end case
- end if
- if c then
- if sprite(10).intersects(7) and ((gLevel = 3) or (gLevel = 4) or (gLevel = 5)) and (gBallDead = 0) then
- gBallDead = 1
- gLives = gLives - 1
- put string(gLives) into member "Lives Display"
- if gLives = 0 then
- waitAWhile()
- case gLevel of
- 1:
- go(6)
- 2:
- go(16)
- 3:
- go(26)
- 4:
- go(36)
- 5:
- go(46)
- end case
- puppetSound(4, "lose")
- member("WinOrLose").text = " Try Again"
- member("WinOrLose2").text = " Try Again"
- member("TotalDisp").text = "Total Score: " & gScore
- member("TotalDisp2").text = "Total Score: " & gScore
- puppetSound(5, "balldead!!!")
- end if
- exit
- end if
- playerRect = sprite(pMySpriteNum).rect
- groundRect = sprite(c).rect
- collisionRect = playerRect.intersect(groundRect)
- if (collisionRect[2] = groundRect[2]) and (pVelocity[2] > 0.0) then
- if (pState <> #onGround) and (pState <> #dead) then
- setState(#onGround)
- end if
- pLocation[2] = collisionRect[2] - (sprite(pMySpriteNum).height / 2) + 5
- end if
- else
- if pState = #onGround then
- setState(#flying)
- end if
- nothing()
- end if
- end
-
- on enemyCollisionCheck
- if sprite(10).blend >= 100 then
- if gBallDead = 0 then
- c = sendSprite(0, #enemyCollisionCheck, pMySpriteNum)
- if c <> 0 then
- if sprite(c).blend = 100 then
- playerRect = sprite(pMySpriteNum).rect
- enemyRect = sprite(c).rect
- collisionRect = playerRect.intersect(enemyRect)
- diffX = collisionRect[3] - collisionRect[1]
- diffY = collisionRect[4] - collisionRect[2]
- if diffY > diffX then
- sendSprite(c, #reverseDirection)
- pVelocity[1] = -pVelocity[1]
- if pVelocity < 0.0 then
- pLocation[1] = collisionRect[1] - (sprite(pMySpriteNum).width / 2) - 1
- else
- pLocation[1] = collisionRect[3] + (sprite(pMySpriteNum).width / 2) + 1
- end if
- else
- if collisionRect[2] = enemyRect[2] then
- if gLevel = 4 then
- if member(sprite(c).member).name = "badguy4" then
- sprite(c).member = member("adguy42")
- else
- sendSprite(c, #die)
- sprite(c).blend = 90
- sprite(pMySpriteNum).locV = sprite(pMySpriteNum).locV - 20
- update()
- pLocation[2] = pLocation[2] - 20
- end if
- else
- if gLevel = 5 then
- if member(sprite(c).member).name = "levelfive_badguy" then
- sprite(c).member = member("evelfive_badguy2")
- else
- sendSprite(c, #die)
- sprite(c).blend = 90
- sprite(pMySpriteNum).locV = sprite(pMySpriteNum).locV - 20
- update()
- pLocation[2] = pLocation[2] - 20
- end if
- else
- sendSprite(c, #die)
- sprite(c).blend = 90
- sprite(pMySpriteNum).locV = sprite(pMySpriteNum).locV - 20
- pLocation[2] = pLocation[2] - 20
- update()
- end if
- end if
- sprite(pMySpriteNum).locV = sprite(pMySpriteNum).locV - 20
- pLocation[2] = pLocation[2] - 20
- pVelocity[2] = 0 - (2 * pVelocity[2])
- if gEnemyCount2 = 0 then
- member("TotalDisp").text = "Total Score: " & gScore
- member("TotalDisp2").text = "Total Score: " & gScore
- waitAWhile()
- case gLevel of
- 1:
- go(2)
- 2:
- go(12)
- 3:
- go(22)
- 4:
- go(32)
- 5:
- member("WinOrLose").text = "You Win!!"
- member("WinOrLose2").text = "You Win!!"
- puppetSound(4, "win10")
- go(46)
- end case
- gLevel = gLevel + 1
- put string(gLevel) into member "LevelDisplay"
- exit
- end if
- else
- gBallDead = 1
- gLives = gLives - 1
- put string(gLives) into member "Lives Display"
- if gLives = 0 then
- waitAWhile()
- case gLevel of
- 1:
- go(6)
- 2:
- go(16)
- 3:
- go(26)
- 4:
- go(36)
- 5:
- go(46)
- end case
- puppetSound(4, "lose")
- member("WinOrLose").text = " Try Again"
- member("WinOrLose2").text = " Try Again"
- member("TotalDisp").text = "Total Score: " & gScore
- member("TotalDisp2").text = "Total Score: " & gScore
- end if
- puppetSound(5, "balldead!!!")
- end if
- end if
- end if
- else
- nothing()
- end if
- end if
- end if
- end
-
- on respawn
- end
-
- on handlePowerup me, powerupType
- case powerupType of
- #freeMan:
- addALife()
- #bonusPoints:
- addScore(1000)
- end case
- end
-